package operation;

import book.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("归还操作");

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入书名");
        String name1 = scanner.nextLine();

        int usedCount = bookList.getUsedSize();
        for (int i = 0; i < usedCount; i++) {
            if(name1.equals(bookList.getBook(i).getName())){
                bookList.getBook(i).setExist(false);
                System.out.println("归还成功");
                return;
            }
        }
        System.out.println("没有这本书，无法归还");
    }
}

